package org.bit.lesson02;

public class Demo206 {
    static boolean isQuit = false;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (!isQuit) {
                System.out.println("hello thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程退出...");
        });

        thread.start();
        // 休眠5秒
        Thread.sleep(5000);
        // 修改标志位表示线程中断
        isQuit = true;
    }
}
